#include "filejudge.h"
#include "ui_filejudge.h"
#include<iostream>

Filejudge::Filejudge(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Filejudge)
{
    ui->setupUi(this);
    InitUi();
}

Filejudge::~Filejudge()
{
    delete ui;
}
void Filejudge::InitUi() {
    ui->editperson->setCheckState(Qt::Checked);
    ui->levelperson->setReadOnly(false);
    connect(ui->Benter,&QPushButton::clicked,this,&Filejudge::Enter);
    connect(ui->Bcancel,&QPushButton::clicked,this,&Filejudge::Cancel);
    connect(ui->editperson,&QCheckBox::clicked,this,&Filejudge::ChangePerEditStatus);
}

void Filejudge::Enter() {
    GetLevelPerFromDialog();
    accept();
}

void Filejudge::Cancel() {
    reject();
}

void Filejudge::ChangePerEditStatus() {
    if(ui->editperson->checkState()==Qt::Checked) {
        ui->levelperson->setReadOnly(false);
    }
    else {
        ui->levelperson->setReadOnly(true);
    }
}
Yzty::FileLevelPerson Filejudge::GetLevelPerFromDialog() {
    Yzty::FileLevelPerson _infor;
    _infor._remarks = ui->remarks->document()->toPlainText();
    _infor._levelper = ui->levelperson->text();
    return _infor;
}
